package com.myblog.controller;

import com.myblog.domain.GlobalResponse;
import com.myblog.domain.dto.GetUserDto;
import com.myblog.domain.dto.UserDto;
import com.myblog.services.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/system/user")
public class UserController {

    @Resource
    UserService userService;

    @PostMapping
    public GlobalResponse addUser(@RequestBody UserDto userDto){
        return userService.addUser(userDto);
    }
    @DeleteMapping("/{id}")
    public GlobalResponse deleteUser(@PathVariable Long id){
        return userService.deleteUser(id);
    }
    @GetMapping("/{id}")
    public GlobalResponse getUser(@PathVariable Long id){
        return userService.getUser(id);
    }

    @PutMapping()
    public GlobalResponse updateUser(@RequestBody GetUserDto user){
        return userService.updateUser(user);

    }
}
